﻿<UserControl
    x:Class="SilverDesigner.PropertiesTool"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    
    xmlns:local1="clr-namespace:SilverDesigner;assembly=SDViewModels" 
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="100">
    <UserControl.Resources>
        <local1:PropertyNameToReadOnlyConverter x:Key="PropertyNameToReadOnlyConverter"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="#DDFFFFFF">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        <ListBox Grid.Row="0" ItemsSource="{Binding Properties}" Background="Transparent">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Width="250">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Text="{Binding PropertyName}" Margin="0,0,5,0" Grid.Row="0" />
                        <TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True"
							IsReadOnly="{Binding PropertyName, Converter={StaticResource PropertyNameToReadOnlyConverter}}"
							VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="1" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <Button x:Name="Delete" Grid.Row="1" Content="Delete" Command="{Binding DeleteCommand}"
                VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                Margin="5" Width="80"
                />
    </Grid>
</UserControl>
    